home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 026-050 / scopedisk42 / extractfont12 / extractfont.doc < prev    next >
Text File  |  1995-03-18  |  4KB  |  141 lines

  1. EXTRACTFONT 1.2 (see note at bottom of docs)
  2.  
  3.    This program will take any standard Amiga font and
  4. create a C Source file so that the font may be used
  5. without having to appear in the user's FONTS:
  6. directory.
  7.    I personally feel this is the way most programs
  8. should operate.  The Only programs that should require
  9. fonts in the FONTS: directory are programs that let
  10. the user choose and use fonts (ie. Graphics and
  11. WYSIWYG style Word Processing programs.)
  12.   The problem with programs that require certain fonts
  13. in the user's FONTS: directory are two fold.  First,
  14. if every program needs a specific font in the user's
  15. FONTS: directory that directory could get very large
  16. and too large for even one disk.  Second, many users
  17. including myself boot from many different boot disks
  18. and it is unreasonable to force the user to either put
  19. your fonts on each of his boot disks or to always boot
  20. from a particular disk when running your program.
  21.  
  22.    Enter EXTRACTFONT.  The program will take any
  23. standard Amiga font and create a C source file that
  24. you can compile and link with your program so that
  25. your fonts are part of your program.
  26.    I have included an example program.  TEST.c  TEST.c
  27. links with a file called SMALL.c that was generated
  28. with EXTRACTFONT.  TEST.c opens a window and prints
  29. some text into that window with the SMALL.font.  Most
  30. program will work this way.
  31.    If you have a multi-tasking type program that needs
  32. to use the same font across tasks then you must
  33. allocate PUBLIC memory and copy the font to this
  34. public memory.  Then call AddFont() to make the font
  35. part of the System's list of fonts.  To use it in
  36. other tasks just call OpenFont and not OpenDiskFont
  37. since it is already in memory.  Aternatively, if you
  38. other tasks/programs open screens just set the
  39. NewScreen.Font to point to a valid TextAttr structure
  40. for your font and your screen will be using the font.
  41. When you are done with the font you can call RemFont()
  42. to remove it from the System's list of fonts.
  43.  
  44.  
  45. Example of multi-program font use.
  46.  
  47. Master Program---
  48.  
  49. ...
  50. /* Font data */
  51.     extern    struct TextFont SmallFont;
  52.     struct    TextFont    *MainFont = 0;
  53.  
  54.     if (!( MainFont = AllocMem (SmallFont.tf_Message.mn_Length, MEMF_PUBLIC)))
  55.         Quit ("Couldn't allocate memory for font");
  56.     CopyMem (&SmallFont, MainFont, SmallFont.tf_Message.mn_Length);
  57.     AddFont (MainFont);
  58.  
  59.     /* Startup subordinate task or program */
  60.  
  61.     /* When all subordinate tasks and programs are done as and
  62.            you are ready to exit... */
  63.  
  64.     if (MainFont)        RemFont (MainFont);
  65. ....
  66.  
  67.  
  68. Subordinate Program
  69. ....
  70. struct Screen *MainScreen = 0;
  71.  
  72. struct TextAttr NormFont = {
  73.     (UBYTE *)"small.font",    /* Font Name        */
  74.     5,            /* Font Height        */
  75.     FS_NORMAL,        /* Style        */
  76.     FPF_DESIGNED };        /* Preferences        */
  77.  
  78. struct NewScreen NewScreen = {
  79.     0, 0,            /* Left, Top Edge        */
  80.     320,200,        /* Width, Height        */
  81.     5,            /* Depth            */
  82.     0, 0,            /* DetailPen, BlockPen        */
  83.     NULL,            /* Display Modes        */
  84.     CUSTOMSCREEN|CUSTOMBITMAP, /* Screen Type        */
  85.     &NormFont,        /* Font                */
  86.     NULL,            /* Title            */
  87.     NULL,            /* Screen Gadgets        */
  88.     NULL,            /* CustomBitMap            */
  89. };
  90.  
  91. MainScreen = OpenScreen (&NewScreen);
  92.  
  93. /* Screen and therefore all windows on this screen are now using the your
  94.    font. */
  95.  
  96. ----or----
  97.  
  98. struct TextFont *YourFont = 0;
  99.  
  100. struct TextAttr NormFont = {
  101.     (UBYTE *)"small.font",    /* Font Name        */
  102.     5,            /* Font Height        */
  103.     FS_NORMAL,        /* Style        */
  104.     FPF_DESIGNED };        /* Preferences        */
  105.  
  106. YourFont = OpenFont (&NormFont);
  107.  
  108. /* Now you can set your RastPort(s) to use the font */
  109.  
  110. SetFont (YourRastPort, YourFont);
  111.  
  112. /* When your done and exiting this task/program you must */
  113.  
  114. CloseFont (YourFont);
  115.  
  116.  
  117.  
  118.  
  119. Good Luck!
  120.      Gregg Tavares
  121.      3332 Mentone Ave #8
  122.      Los Angeles, CA 90034
  123.  
  124.      CIS: 72411,2772
  125.      PeopleLink: GreggT
  126.  
  127.  
  128.  
  129. Note: The orignal version of this program had a
  130. "bug".  I had assumed (don't ask me why) that all
  131. fonts required Space and Kern fields even if they
  132. were Fixed-Width fonts.  Well I was wrong.  That
  133. assumption has been fixed and the program should now
  134. work with all your fonts.  (excluding ColorFonts).
  135.   Also, someone (sorry I forgot to note your name)
  136. suggested I make many of the font parts "static" so
  137. that you can include many fonts in one program
  138. without having to edit the 'C' source files created
  139. by EXTRACTFONT.  Well I had added this suggestion and
  140. it works well.  Thank you to whomever suggested it.
  141.